#!/usr/bin/env python
# encoding: utf-8
"""
@File    : base_utils.py
@Time    : 2021/5/21 15:04
@Author  : W
@Software: PyCharm
"""
import time
from functools import wraps
from base_class.inspect_logging import print_to_log


def spend_time(msg):
    """
    :param msg: 啥都行
    :return: 所消耗时间
    """
    def count_time_core(func):
        @wraps(func)
        def inner(*args, **kwargs):
            a = time.time()
            ans = func(*args, **kwargs)
            b = time.time()
            print_to_log(f'"{msg}" costs: %.2fs' % (b - a))
            return ans
        return inner
    return count_time_core